package org.shj.springcloud.movie.controller;

import java.util.Map;

import org.shj.springcloud.movie.conf.FeignConfiguration;
import org.shj.springcloud.movie.pojo.User;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * configuration 属性是指 自定义的 Feign配置
 * @author huangjian
 *
 */
@FeignClient(name="microservice-provider-user", configuration = FeignConfiguration.class)
public interface UserFeignClient {

	/* Spring 提供的注解 */
	@RequestMapping(value="/{id}", method=RequestMethod.GET)
	public User findById(@PathVariable("id") String id);
	
	/* @RequestLine 为 Feign 自带的注解 
	@RequestLine("GET /{id}")
	public User findById(@Param("id") String id);
	*/
	
	//多个参数写法1
	@RequestMapping(value="/get", method=RequestMethod.GET)
	public User get1(@RequestParam("id") String id, @RequestParam("username") String username);
	
	//多个参数写法2
	@RequestMapping(value="/get", method=RequestMethod.GET)
	public User get2(@RequestParam Map<String, Object> map);
	
	// post 一个对象的写法
	@RequestMapping(value="/post", method = RequestMethod.POST)
	public User post(@RequestBody User user);
	
}
